<template>
  <div>
    <div>{{hour}}:{{minute}}:{{seconds}}</div>
    <button @click="intervalFn">秒杀</button>
  </div>
</template>

<script>
export default {
    data(){
      return{
        totalTime:10800,
        hour:3,
        minute:0,
        seconds:0
      }
    },
    methods:{
      intervalFn(){
        let timer = setInterval(()=>{
          if(this.totalTime>= 0){
                     //  console.log(1);
                       var hour = Math.floor(this.totalTime/3600)
                       var minute = Math.floor(this.totalTime%3600/60)
                       var seconds = Math.floor(this.totalTime%60)
                       this.hour = hour
                       this.minute = minute
                       this.seconds = seconds
                       this.totalTime--;
                      console.log(hour, minute,seconds);
                      console.log('赋值  ----->  ', this.hour,this.minute,this.seconds);
          }else{
            clearInterval(this.timer)
          }
        },1000)
        console.log('timer  ----->  ', timer);
          

      }
    }
}
</script>

<style>

</style>